<div class="tpl-content-page-title">商品信息</div>
<ol class="am-breadcrumb">
	<li><a href="#" class="am-icon-home">首页</a></li>
	<li><a href="#">云造型会员</a></li>
	<li class="am-active">商品信息</li>
</ol>
<div class="tpl-portlet-components">
	<div class="tpl-block">
		<div class="am-g">
			<div class="am-u-sm-12 am-u-md-6">
				<div class="am-btn-toolbar">
					<div class="am-btn-group am-btn-group-xs">
						<!--  <button type="button" class="am-btn am-btn-default am-btn-success bnt-add">
							<span class="am-icon-plus"></span> 添加
						</button> 
						 <button id="payId" type="button" class="am-btn am-btn-default am-btn-warning
						 bnt-update">
							<span class="am-icon-archive"></span> 修改
						</button>
						<button type="button" class="am-btn am-btn-default am-btn-danger">
							<span class="am-icon-trash-o"></span> 删除
						</button> -->
					</div>
				</div>
			</div>
			<div class="am-u-sm-12 am-u-md-3">
				<div class="am-input-group am-input-group-sm">
					<!-- <input type="text" class="am-form-field"> --> <span
						class="am-input-group-btn">
						<!-- <button
							class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search"
							type="button"></button> -->
					</span>
				</div>
			</div>
		</div>
		<div class="am-g">
			<div class="am-u-sm-12">
				<form class="am-form">
					<table class="am-table am-table-striped am-table-hover table-main">
						<thead>
							<tr>
								<th class="table-check"><input type="checkbox"
									class="tpl-table-fz-check"></th>
								<th class="table-title">商品名称</th>
								<th class="table-title">商品价格</th>
								<th class="table-title">商品详情</th>
								<th class="table-author am-hide-sm-only">创建时间</th>
								<th class="table-author am-hide-sm-only">修改时间</th>
								<!-- <th class="table-date am-hide-sm-only">操作</th> -->
							</tr>
						</thead>
						<tbody id="tbodyId">
							<tr>
								<td colspan="9">商品暂未上架</td>
							</tr>
						</tbody>
					</table>
					<div class="am-cf">

						<div class="am-fr">
							<ul class="am-pagination tpl-pagination">
								<li><a class="first">首页</a></li>
								<li><a class="pre">上一页</a></li>
								<li><a class="next">下一页</a></li>
								<li><a class="last">尾页</a></li>
								<li><a class="rowCount">总记录数(0)</a></li>
								<li><a class="pageCount">总页数(1)</a></li>
								<li><a class="pageCurrent">当前页(1)</a></li>
							</ul>
						</div>
					</div>
					<hr>

				</form>
			</div>

		</div>
	</div>
	<div class="tpl-alert"></div>
</div>
<script type="text/javascript">
$(function(){
	doGetObjects()
	 $(".tpl-content-wrapper")
	 .on("click",".btn-item-delete",itemDeleteById);
});


//基于id删除会员信息
function itemDeleteById(){
	debugger
	// 1.获取选中的checkbox的会员
	var idArray =doGetCheckedMember();
	//2.校验数组内容
 if(idArray.length==0){
	   alert("请先选择");
	   return;
 }
	
 //3.给出提示，确定删除吗？
 if(!confirm("确定删除吗"))return;


	var url = "item/doDeleteByMobile";
	var mobiles = checked
	
	var params = {"id":id};
	// 发送异步请求 
	$.get(url,params,function(result){
		if(result.state==1){
			alert(result.message)
			doGetObjects()
		}else{
			alert(result.message)
		}
	}); 
	
}

//查询所有会员信息
function doGetObjects(){
	var url="item/doFindPageObjects";
	//debugger
	// 当前页数据
	var pageCurrent=$(".tpl-pagination").data("pageCurrent");
	if(!pageCurrent){pageCurrent=1;}
	// 参数
	var params={"pageCurrent":pageCurrent}
	var uname=$("#searchNameId").val();
	if(uname){
		params.username=uname;
	}
	$.getJSON(url,params,function(result){
		console.log(result)
		doHandleResponseResult(result)
	})
}

// 将响应的数据进行筛选判断
function doHandleResponseResult(result){
	if(result.state==1){
		doSetTablebody(result.data.records)
		doSetPagination(result.data);
	}else{
		alert(result.message)
	}
}

// 追加数据
function doSetTablebody(records){
	// 获取tbodyId元素对象，并清空数据
	var tb=$("#tbodyId")
	tb.empty();
	// 循环追加
	for(var i in records){
		// 创建tr对象和tds对象
		var tr=$("<tr></tr>");
		// 给每一个tr的data属性绑定id值
		tr.data("id",records[i].id);
		var tds=doCreateIds(records[i]);
		// 追加数据
		tr.append(tds);
		tb.append(tr);
	}
}

// 绑定数据
function doCreateIds(records){   
	var ids="<td><input type='checkbox' class='cbox' value='"+records.id+"' /></td>"+
			"<td>"+records.itemName+"</td>"+
			"<td>"+records.itemPrice+".00"+"</td>"+
			"<td>"+records.itemDetails+"</td>"+
			"<td>"+new Date(records.createdTime).toLocaleString()+"</td>"+
			"<td>"+new Date(records.modifiedTime).toLocaleString()+"</td>";
		/* 	"<td><a class='btn-item-delete'>删除</a></td>"; */
	return ids; // 返回绑定数据
}



</script>
<script type="text/javascript" src="../assets/js/page.js"></script>
</body>

</html>












